<?
$page = "modelosversoes";

?>
<div class="container-form">
    <h1>Modelos x Versões</h1>
    <form action="<?= __ADMIN_URI__; ?>actions/<?= $page ?>.php" method="post" enctype="multipart/form-data" id="form-cadastre" onsubmit="return Validation();">
        <input type="hidden" name="redirect" id="redirect" value="<?= __ADMIN_URI__ . $page ?>">
        <input type="hidden" name="id" id="codigo" value="<?= $data[0]['id']; ?>">
        <div class="input">
            Modelo:
            <select name="modelo" id="modelo">
                <option value=""></option>
                <?foreach (ModelosControl::Listar() as $t){ ?>
                <option value="<?=$t['id'];?>"><?=$t['name'];?></option>
                <? } ?>
            </select>
            Modelo:
            <select name="versao" id="versao">
                <option value=""></option>
                <?foreach (VersoesControl::Listar() as $t){ ?>
                <option value="<?=$t['id'];?>"><?=$t['name'];?></option>
                <? } ?>
            </select>
        </div>
        
        <div class="input">
            <input type="submit" value="Salvar">
            <input type="button" value="Novo" onclick="location.href = $('#redirect').val();">
        </div>
    </form>
    <hr>
    <div class="list">
        <div class="list-data">
            <ul>
                <li>Modelo</li>
                <li>Versão</li>
                <li>Opções</li>
            </ul>
            <?php
            foreach (ModelosVersoesControl::Select() as $list) {
                $urldelete = __ADMIN_URI__ . "actions/" . $page . ".php?id_modelo=" . $list['id_modelo'] . "&id_versao=" . $list['id_versao'] . "&redirect=" . __ADMIN_URI__ . $page;
                ?>
                <ul>
                    <li><?= $list['modelo']; ?></li>
                    <li><?= $list['versao']; ?></li>
                    <li><a href="javascript:ApagarRegistro('<?=$urldelete?>')">Excluir</a></li>
                </ul>
                <?
            }
            ?>

        </div>
    </div>
</div>

